#include "datastructures.h"

//===========================================================================================================
// Constructs
//===========================================================================================================
SS::SS()
{
	comps_list = NULL;
	comps_list = new List<SSComp>;

	Reset();
}

SS::SS(SS *copy)
{
	comps_list = NULL;
	comps_list = new List<SSComp>;

	copy->CopyTo(this);
}
//-----------------------------------------------------------------------------------------------------------
SS::~SS()
{
	delete comps_list;
}
//-----------------------------------------------------------------------------------------------------------
void SS::Reset()
{
	comps_list->Clear();

	a0 = 0.0;
  a1 = 0.0;
	tk = (LDBLE)298.15;
	dn = 0.0;
	ag0 = 0.0;
	ag1 = 0.0;
	xb1 = 0.0;
	xb2 = 0.0;
	total_moles = (LDBLE)NAN;

	for(int i = 0; i < 4; i++)
		p[i] = 0.0;

	name = "";

  input_case = 0;

  miscibility = false;
	spinodal = false;
	s_s_in = false;  
	ideal = true;
}
//-----------------------------------------------------------------------------------------------------------
void SS::CopyTo(SS* copy)
{
	comps_list->CopyTo(copy->comps_list);

	copy->a0 = a0;
  copy->a1 = a1;
	copy->tk = tk;
	copy->dn = dn;
	copy->ag0 = ag0;
	copy->ag1 = ag1;
	copy->xb1 = xb1;
	copy->xb2 = xb2;

	for(int i = 0; i < 4; i++)
		copy->p[i] = p[i];

	copy->name = name;

  copy->input_case = input_case;
  copy->miscibility = miscibility;
	copy->spinodal = spinodal;
	copy->s_s_in = s_s_in;
  copy->ideal = ideal;

	copy->total_moles = total_moles;
}
//-----------------------------------------------------------------------------------------------------------
/*
SS* SS::Copy()
{
	return new SS(this);
}
*/
//-----------------------------------------------------------------------------------------------------------
bool SS::AddComp(struct SSCompData *comp_data)
{
	if (comp_data->name == "" || (!ideal && comps_list->Count() >= 2))
		return false;

	SSComp *ssc = comps_list->AddNew();

	ssc->name = comp_data->name;
	ssc->moles = comp_data->moles;

	return true;
}
//-----------------------------------------------------------------------------------------------------------
void SS::NondimensionalGuggenheim(LDBLE p0, LDBLE p1)
{
	p[0] = p0;
	p[1] = p1;
	input_case = 0;
}
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------
